package ynu.czs.feign;

import ynu.czs.pojo.Cart;
import ynu.czs.pojo.Food;
import ynu.czs.pojo.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * 食品服务 Feign 客户端
 */
@FeignClient(name = "food-service")
public interface FoodFeignClient {

    /**
     * 获取商家下的所有食品
     */
    @GetMapping("/food/businessId/{businessId}")
    Result listFoodByBusinessId(@PathVariable("businessId") Integer businessId);

    /**
     * 获取商家下的食品列表（带用户信息）
     */
    @GetMapping("/food/{businessId}/{userId}")
    Result listFood(@PathVariable("businessId") Integer businessId,
                    @PathVariable("userId") Long userId);

    /**
     * 获取用户购物车中特定食品的信息
     */
    @GetMapping("/food/getCart/{foodId}/{userId}")
    Result getCart(@PathVariable("foodId") Integer foodId,
                   @PathVariable("userId") Long userId);

    /**
     * 添加新食品
     */
    @PostMapping("/food")
    Result addFood(@RequestBody Food food);

    /**
     * 删除食品
     */
    @DeleteMapping("/food/{foodId}")
    Result deleteFood(@PathVariable("foodId") Integer foodId);
}